{\rtf0\ansi{\fonttbl\f2\fmodern Courier;\f5\ftech Symbol;\f6\fmodern Ohlfs;}
\margl40
\margr40
\pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f2\b0\i0\ulnone\fs24\fc0\cf0 //ппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
//
\i 	
\b FILENAME
\b0 :	
\b\i0 eTDocInfoUI.m\

\b0 //
\i 	
\b SUMMARY
\b0 :	
\b\i0 Inspector/Controller for eText-based eTDocInfos
\b0 \
//	
\b\i SUPERCLASS
\b0 :
\i0 	
\b Object:eTDocInfoUI
\b0 \
//	
\b\i PROTOCOLS
\b0 :
\i0 	
\b <Inspectable>
\b0 \
//	
\b\i INTERFACE
\b0 :
\i0 	
\b eTDocInfoUI.nib
\b0 \
//	
\b\i AUTHOR
\b0 :		
\b\i0 Rohit Khare
\b0 \
//	
\b\i COPYRIGHT
\b0 :	
\f5\i0 с
\f2\b 1993,94 California Institure of Technology, eText Project\

\b0 //ппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
//	
\b\i Implementation Commnents
\b0\i0 \
//		This is a shared inspector (once copy of the nibs, can inspect any\
//	eText DocInfo). It is also used as an "implicit" annotation in eText docs.\
//ппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
//	
\b\i HISTORY\

\b0\i0 //	10/31/94:	
\b Changed fontwell setup completely.
\b0 \
//	10/04/94:	
\b Revamped for eText5; renamed eTDocInfoUI
\b0 \
//	01/15/94:	
\b Created for eText4.0. Borrows from DocInspector in eText3.0
\b0 \
//ппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
//	
\b Imported Interfaces
\b0 \
//\
	#import "
\b eTDocInfoUI.h
\b0 "\
\

\i @implementation eTDocInfoUI\

\i0 //ппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
// 	
\b Class Management
\b0 \
//\
+ 
\b new
\b0  \{\
	
\b static
\b0  eTDocInfoUI *
\b ui
\b0  = 
\b nil
\b0 ;\
	\
	if (
\b !ui
\b0 ) \{\
		
\b ui
\b0  = [[
\b eTDocInfoUI
\b0  alloc] 
\b init
\b0 ];\
	\}\
	
\b return
\b0  ui;\
\}\
- 
\b free
\b0  \{\
	return 
\b self
\b0 ;\}\
- 
\b init
\b0  \{\
	char        
\b buf
\b0 [MAXPATHLEN];\
	NXBundle   *
\b bundle
\b0 ;\
\
	[super 
\b init
\b0 ];\
	
\b bundle
\b0  = [
\b NXBundle
\b0  bundleForClass:[
\b eTDocInfoUI
\b0  class]];\
	if ([
\b bundle
\b0  
\b getPath
\b0 :buf 
\b forResource
\b0 :"
\b eTDocInfoUI
\b0 " 
\b ofType
\b0 :"
\b nib
\b0 "] ) \{\
		[NXApp 
\b loadNibFile
\b0 :buf 
\b owner
\b0 :self 
\b withNames
\b0 :NO];\
	\} else \{\
		NXLogError("
\b NIB not found: eTDocInfoUI
\b0 ");\
	\}\
\
	
\b infoView
\b0  = [
\b infoPanel
\b0  
\b contentView
\b0 ];\
	
\b docInfoView
\b0  = [
\b docInfoPanel
\b0  
\b contentView
\b0 ];\
	
\b taggingView
\b0  = [
\b taggingPanel
\b0  
\b contentView
\b0 ];\
	[
\b heading1Well
\b0  setStr:NXUniqueString("
\b <H1>
\b0 ")];\
	[
\b heading2Well
\b0  setStr:NXUniqueString("
\b <H2>
\b0 ")];\
	[
\b heading3Well
\b0  setStr:NXUniqueString("
\b <H3>
\b0 ")];\
	[
\b heading4Well
\b0  setStr:NXUniqueString("
\b <H4>
\b0 ")];\
	[
\b heading5Well
\b0  setStr:NXUniqueString("
\b <H5>
\b0 ")];\
	[
\b heading6Well
\b0  setStr:NXUniqueString("
\b <H6>
\b0 ")];\
	[
\b quotationWell
\b0  setStr:NXUniqueString("
\b <BLOCKQUOTE>
\b0 ")];\
	[
\b bodyWell
\b0  setStr:NXUniqueString("
\b Body Text
\b0 ")];\
	[
\b peersWell
\b0  
\b initLinkWell
\b0 ];\
	[
\b parentWell
\b0  
\b initLinkWell
\b0 ];\
	[
\b comments
\b0  setDelegate:self];\
\
	return self;\
\}\
- 
\b setDocInfo
\b0 :newDocInfo \{\
	
\b theDocInfo
\b0  = 
\b newDocInfo
\b0 ; return self;\}\
\
\
//ппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
// 	
\b UI Callbacks
\b0 \
//\
- 
\b accept
\b0 :sender;					// 
\i From eTLinkWells
\i0 \
\{\
	if (
\b sender
\b0  == 
\b parent
\b0 Well)\{\
		[
\b parent
\b0  
\b setStringValue
\b0 :[sender 
\b currentLink
\b0 ]->
\b docID
\b0 ];\
		[
\b theDocInfo
\b0  
\b setParent
\b0 :[sender 
\b currentLink
\b0 ]->
\b docID
\b0 ];\
	\} else if (
\b sender
\b0  == 
\b peers
\b0 Well) \{\
		char 
\b buf
\b0 [MAXPATHLEN];\
		
\b sprintf
\b0 (buf, "
\b %s %s
\b0 ", [sender 
\b currentLink
\b0 ]->
\b docID
\b0 ,[
\b peers
\b0  
\b stringValue
\b0 ]);\
		[
\b peers
\b0  
\b setStringValue
\b0 :buf];\
		[
\b theDocInfo
\b0  
\b setPeers
\b0 :buf];\
	\}\
	return [self touch];\
\}\
- 
\b textDidGetKeys
\b0 :sender 
\b isEmpty
\b0 :(BOOL)flag \{\
	return [self touch];\}\
- 
\b textWillConvert
\b0 :sender 
\b fromFont
\b0 :from 
\b toFont
\b0 :to \{\
	[self touch]; return to;\}\
- 
\b touch
\b0 :sender \{					// 
\i The FormCell action: method\

\i0 	return [[
\b theDocInfo
\b0  
\b etDoc
\b0 ] 
\b touch
\b0 ];\}\
- 
\b touch
\b0  \{\
	return [[
\b theDocInfo
\b0  
\b etDoc
\b0 ] 
\b touch
\b0 ];\}\
\
//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
//	
\b <Inspectable> Obligations
\b0 \
//\
- (const char *) 
\b inspectorTitle
\b0  \{return NXUniqueString("
\b DocInfo
\b0 ");\}\
- (const NXAtom *) 
\b types
\b0  \{\
	
\b static
\b0  NXAtom *
\b typesForInspector
\b0 =NULL;\
	\
	if (!typesForInspector) \{\
		typesForInspector = 
\b malloc
\b0 (
\b 4
\b0  * sizeof(NXAtom));\
		typesForInspector[0] = NXUniqueString(
\b PROP
\b0 );\
		typesForInspector[1] = NXUniqueString(
\b TAGS
\b0 );\
		typesForInspector[2] = NXUniqueString(
\b INFO
\b0 );\
		typesForInspector[3] = 
\b NULL
\b0 ;\
	\}\
	
\b return
\b0  
\b typesForInspector
\b0 ;\
\}\
- 
\b inspectorForType
\b0 :(const char *) type \{\
	if(!strcmp(
\b type
\b0 ,NXUniqueString(
\b PROP
\b0 )))\
		return 
\b docInfoView
\b0 ;\
	else if (!strcmp(
\b type
\b0 ,NXUniqueString(
\b TAGS
\b0 )))\
		return 
\b taggingView
\b0 ;\
	else if (!strcmp(
\b type
\b0 ,NXUniqueString(
\b INFO
\b0 )))\
		return 
\b infoView
\b0 ;\
	NXLogError("
\b Massive Inspector Failure: Asked eTDocInfoUI for: %s
\b0 ", 
\b type
\b0 );\
	return 
\b docInfoView
\b0 ;\
\}\
- 
\b resignInspector
\b0 : (View *) 
\b oldInspector
\b0  
\b ofType
\b0 : (const char *) 
\b type
\b0  \{\
	if ((oldInspector == 
\b docInfoView
\b0 ) 
\b &&
\b0  [theDocInfo 
\b etDoc
\b0 ])\{\

\b 		NXStream
\b0  	*
\b stream
\b0 ;\
		
\b char
\b0 		*
\b buffer
\b0 , *
\b data
\b0 ;\
		
\b int
\b0 			
\b length
\b0 , 
\b maxlen
\b0 ;\
\
		[theDocInfo 
\b setDocTitle
\b0 :[
\b title
\b0  stringValue]];\
		[theDocInfo 
\b setAuthor
\b0 :[
\b author
\b0  stringValue]];\
		[theDocInfo 
\b setKeywords
\b0 :[
\b keywords
\b0  stringValue]];\
		[theDocInfo 
\b setParent
\b0 :[
\b parent
\b0  stringValue]];\
		[theDocInfo 
\b setPeers
\b0 :[
\b peers
\b0  stringValue]];\
		// 
\i Note that this call is in the eText category of theDocInfo; eDraw?
\i0 \
		[theDocInfo 
\b setEmitTrailer
\b0 :(BOOL)[
\b trailerSw
\b0  
\b state
\b0 ]];\
		\
		
\b stream
\b0  = 
\b NXOpenMemory
\b0 (NULL, 0, 
\b NX_WRITEONLY
\b0 );\
		[
\b comments
\b0  
\b writeRichText
\b0 :
\b stream
\b0 ];\
		
\b NXGetMemoryBuffer
\b0 (
\b stream
\b0 , &
\b buffer
\b0 , &
\b length
\b0 , &
\b maxlen
\b0 );\
		
\b data
\b0  = 
\b malloc
\b0 ((
\b length
\b0 +1) * sizeof(
\b char
\b0 ));\
		
\b bcopy
\b0 (
\b buffer
\b0 , 
\b data
\b0 , length);\
		data[length] = 0;\
		
\b NXCloseMemory
\b0 (
\b stream
\b0 , 
\b NX_FREEBUFFER
\b0 );\
		[
\b theDocInfo
\b0  
\b setRTFComments
\b0 :NXUniqueString(
\b data
\b0 )];\
		
\b free
\b0 (data);\
		\
		[
\b navigator
\b0  
\b touch
\b0 ];\
	\
	\} else if ((oldInspector == 
\b taggingView
\b0 ) 
\b &&
\b0  [theDocInfo 
\b etDoc
\b0 ])\{\
		[theDocInfo 
\b setTag
\b0 :
\b H1
\b0  to:[
\b heading1
\b0 Well 
\b font
\b0 ]];\
		[theDocInfo 
\b setTag
\b0 :
\b H2
\b0  to:[
\b heading2
\b0 Well 
\b font
\b0 ]];\
		[theDocInfo 
\b setTag
\b0 :
\b H3
\b0  to:[
\b heading3
\b0 Well 
\b font
\b0 ]];\
		[theDocInfo 
\b setTag
\b0 :
\b H4
\b0  to:[
\b heading4
\b0 Well 
\b font
\b0 ]];\
		[theDocInfo 
\b setTag
\b0 :
\b H5
\b0  to:[
\b heading5
\b0 Well 
\b font
\b0 ]];\
		[theDocInfo 
\b setTag
\b0 :
\b H6
\b0  to:[
\b heading6
\b0 Well 
\b font
\b0 ]];\
		[theDocInfo 
\b setTag
\b0 :
\b QT
\b0  to:[
\b quotation
\b0 Well 
\b font
\b0 ]];\
		[theDocInfo 
\b setTag
\b0 :
\b BODY
\b0  to:[
\b body
\b0 Well 
\b font
\b0 ]];\
	\}\
	return self;\
\}\
- 
\b activateInspector
\b0 : (View *) 
\b newInspector
\b0  
\b ofType
\b0 : (const char *) 
\b type
\b0  \{\
	if (newInspector == 
\b docInfoView
\b0 ) \{\

\b 		NXStream
\b0  	*
\b stream
\b0 ;\

\b 		char
\b0 		*
\b buf
\b0 ;\
		BOOL		 editOK;\
		\
		[
\b docIDField
\b0  setStringValue:[theDocInfo 
\b docIDStr
\b0 ]];\
		[
\b dateField
\b0  setStringValue:[theDocInfo 
\b lastModifyDate
\b0 ]];\
		[
\b title
\b0  setStringValue:[theDocInfo 
\b docTitle
\b0 ]];\
		[
\b keywords
\b0  setStringValue:[theDocInfo 
\b keywords
\b0 ]];\
		[
\b author
\b0  setStringValue:[theDocInfo 
\b author
\b0 ]];\
		[
\b parent
\b0  setStringValue:[theDocInfo 
\b parent
\b0 ]];\
		[
\b peers
\b0  setStringValue:[theDocInfo 
\b peers
\b0 ]];\
		// 
\i Note that this call is in the eText category of theDocInfo; eDraw?
\i0 \
		[
\b trailerSw
\b0  setState:[theDocInfo 
\b emitTrailer
\b0 ]];\

\b 		buf
\b0  = (char *)[theDocInfo 
\b rtfComments
\b0 ];\
		if (buf) \{\

\b 			stream
\b0  = 
\b NXOpenMemory
\b0 (
\b buf
\b0 ,strlen(buf), 
\b NX_READONLY
\b0 );\
			[
\b comments
\b0  
\b readRichText
\b0 :stream];\

\b 			NXClose
\b0 (stream);\
		\} else \{\
			[
\b comments
\b0  setSel:0 :[comments textLength]];\
			[comments 
\b setText
\b0 :""];\
		\}\
		editOK = ([theDocInfo etDoc] != nil);\
		[
\b docIDField
\b0  setEditable:
\b editOK
\b0 ];\
		[
\b dateField
\b0  	setEditable:
\b editOK
\b0 ];\
		[
\b title
\b0  		setEditable:
\b editOK
\b0 ];\
		[
\b keywords
\b0  	setEditable:
\b editOK
\b0 ];\
		[
\b author
\b0  	setEditable:
\b editOK
\b0 ];\
		[
\b parent
\b0  	setEditable:
\b editOK
\b0 ];\
		[
\b peers
\b0  		setEditable:
\b editOK
\b0 ];\
		[
\b trailerSw
\b0  	setEnabled:
\b editOK
\b0 ];\
		[
\b comments
\b0  	setEditable:
\b editOK
\b0 ];\
	\} else if (newInspector == 
\b taggingView
\b0 ) \{\
		BOOL editOK = ([theDocInfo etDoc] != nil);\
	\
		[
\b heading1
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b H1
\b0 ]];\
		[
\b heading1
\b0 Well	setEnabled:editOK];\
		[
\b heading2
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b H2
\b0 ]];\
		[
\b heading2
\b0 Well	setEnabled:editOK];\
		[
\b heading3
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b H3
\b0 ]];\
		[
\b heading3
\b0 Well	setEnabled:editOK];\
		[
\b heading4
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b H4
\b0 ]];\
		[
\b heading4
\b0 Well	setEnabled:editOK];\
		[
\b heading5
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b H5
\b0 ]];\
		[
\b heading5
\b0 Well	setEnabled:editOK];\
		[
\b heading6
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b H6
\b0 ]];\
		[
\b heading6
\b0 Well	setEnabled:editOK];\
		[
\b quotation
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b QT
\b0 ]];\
		[
\b quotation
\b0 Well	setEnabled:editOK];\
		[
\b body
\b0 Well		
\b setFont
\b0 :[theDocInfo 
\b tagFont
\b0 :
\b BODY
\b0 ]];\
		[
\b body
\b0 Well		setEnabled:editOK];\
	\}\
	return self;\
\}\

\i @end\

\i0 \
//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
//	
\b Text-specific Extensions
\b0 \
//\

\i @implementation eTDocInfoUI(eText)\

\i0 //пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп\
//	
\b Tagging Fonts
\b0 \
//\
- 
\b setDefaultTags
\b0 :sender \{\
	[theDocInfo 
\b registerTag
\b0 :
\b H1
\b0  to:[
\b heading1
\b0 Well 
\b font
\b0 ]];\
	[theDocInfo 
\b registerTag
\b0 :
\b H2
\b0  to:[
\b heading2
\b0 Well 
\b font
\b0 ]];\
	[theDocInfo 
\b registerTag
\b0 :
\b H3
\b0  to:[
\b heading3
\b0 Well 
\b font
\b0 ]];\
	[theDocInfo 
\b registerTag
\b0 :
\b H4
\b0  to:[
\b heading4
\b0 Well 
\b font
\b0 ]];\
	[theDocInfo 
\b registerTag
\b0 :
\b H5
\b0  to:[
\b heading5
\b0 Well 
\b font
\b0 ]];\
	[theDocInfo 
\b registerTag
\b0 :
\b H6
\b0  to:[
\b heading6
\b0 Well 
\b font
\b0 ]];\
	[theDocInfo 
\b registerTag
\b0 :
\b QT
\b0  to:[
\b quotation
\b0 Well 
\b font
\b0 ]];\
	[theDocInfo 
\b registerTag
\b0 :
\b BODY
\b0  to:[
\b body
\b0 Well 
\b font
\b0 ]];\
	return [self touch];\
\}\
- 
\b getDefaultTags
\b0 :sender \{\
	[
\b heading1
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b H1
\b0 ]];\
	[
\b heading2
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b H2
\b0 ]];\
	[
\b heading3
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b H3
\b0 ]];\
	[
\b heading4
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b H4
\b0 ]];\
	[
\b heading5
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b H5
\b0 ]];\
	[
\b heading6
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b H6
\b0 ]];\
	[
\b quotation
\b0 Well	
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b QT
\b0 ]];\
	[
\b body
\b0 Well		
\b setFont
\b0 :[theDocInfo 
\b defaultTagFont
\b0 :
\b BODY
\b0 ]];	return [self touch];\
\}\
\
- 
\b changeTagFont
\b0 :sender \{\
	if ([
\b sender
\b0  
\b isKindOf
\b0 :[
\b FontWell
\b0  class]]) \{\
		int 
\b choice
\b0  = 
\b NXRunAlertPanel
\b0 ("
\b Change Tagging Font
\b0 ",\
					"
\b Would you like to replace all instances of this tag 
\b0 "\
					"
\b font in your document? This can't be undone.
\b0 ",\
					"
\b Replace
\b0 ", "
\b Don't Replace
\b0 ", "
\b Cancel
\b0 ");\
		if (choice == 
\b NX_ALERTOTHER
\b0 ) \{return 
\b nil
\b0 ;\}\
		else if (choice == 
\b NX_ALERTDEFAULT
\b0 ) \{\
			// 
\i OK, so now we want to message eTextObj to replace fonts\

\i0 			[[[[theDocInfo 
\b etDoc
\b0 ] 
\b docUI
\b0 ] 
\b eTextObj
\b0 ]\
				 
\b replaceFont
\b0 :[sender 
\b font
\b0 ] 
\b with
\b0 :[sender 
\b proposedFont
\b0 ]];\
		\}\
		[
\b self
\b0  
\b touch
\b0 ];\
	\}\
	return self;\}\
	\
- (
\b Font
\b0  *)
\b heading1
\b0  \{\
	return [
\b heading1
\b0 Well 
\b font
\b0 ];\}\
- (
\b Font
\b0  *)
\b heading2
\b0  \{\
	return [
\b heading2
\b0 Well 
\b font
\b0 ];\}\
- (
\b Font
\b0  *)
\b heading3
\b0  \{\
	return [
\b heading3
\b0 Well 
\b font
\b0 ];\}\
- (
\b Font
\b0  *)
\b heading4
\b0  \{\
	return [
\b heading4
\b0 Well 
\b font
\b0 ];\}\
- (
\b Font
\b0  *)
\b heading5
\b0  \{\
	return [
\b heading5
\b0 Well 
\b font
\b0 ];\}\
- (
\b Font
\b0  *)
\b heading6
\b0  \{\
	return [
\b heading6
\b0 Well 
\b font
\b0 ];\}\
- (
\b Font
\b0  *)
\b quotation
\b0  \{\
	return [
\b quotation
\b0 Well 
\b font
\b0 ];\}\
- (
\b Font
\b0  *)
\b body
\b0  \{\
	return [
\b body
\b0 Well 
\b font
\b0 ];\}\
\

\i @end
}
